package Beans;

import Entities.World;
import World.FileWorldListLoader;
import World.WorldListLoader;
import java.util.ArrayList;
import javax.ejb.LocalBean;
import javax.ejb.Stateful;

@Stateful
@LocalBean
public class WorldBean {

    private int currentWorld = 0;
    private WorldListLoader worldLoader;
    private ArrayList<World> worldList;

    public ArrayList<World> loadWorldList() {

        worldLoader = new FileWorldListLoader();
        worldList = worldLoader.loadWorldList();

        if (worldList.size() > 9) {
            worldList = (ArrayList<World>) worldList.subList(currentWorld, currentWorld + 8);
            currentWorld = currentWorld + 9;
        }
        return worldList;
    }
}
